local monitor=peripheral.find("monitor")
local pd=peripheral.find("playerDetector")
local players=pd.getOnlinePlayers()
local maxLine=26
-- while true do

-- monitor.clear()
local clrs={
    colors.white,
    colors.orange,
    colors.magenta,
    colors.lightBlue,
    colors.yellow,
    colors.lime,
    colors.pink,
    colors.gray,
    colors.lightGray,
    colors.cyan,
    colors.purple,
    colors.blue,
    colors.brown,
    colors.green,
    colors.red,
}

local lines={
    [[ __          __  _  _____  ]],
    [[ \ \        / / | |/ ____|                    ]],
    [[  \ \  /\  / /__| | |     ___  _ __ ___   ___ ]],
    [[   \ \/  \/ / _ \ | |    / _ \| '_ ` _ \ / _ \]],
    [[    \  /\  /  __/ | |___| (_) | | | | | |  __/]],
    [[     \/  \/ \___|_|\_____\___/|_| |_| |_|\___|]]
}
-- term.setTextColour(colors.red)
local clrindex=1
while true do
    
    -- term.clear()
    clrindex=clrindex+1
        if clrindex>=#clrs then
            clrindex=1
        end
    shell.run("clear")
    for y=1,maxLine,1 do
        
        monitor.setCursorPos(1, y)
        monitor.clearLine()
        
        if (y<=#lines)then
            -- textutils.tabulate(
            -- clrs[(clrindex+y)%#clrs+1], { lines[y].."\n" }
            -- )
            -- term.setPaletteColour(colors.red, (0xFF00000+0x0001000*y*2))
            monitor.setTextColor(clrs[(clrindex+y)%#clrs+1])
            -- print( (0xFF0000+0x001000*y*2))
            -- print(lines[y].."\n")
            
            monitor.write(lines[y])
        else
            if (players[y-#lines] == nil) then
                break
            end
            local pos=pd.getPlayerPos(players[y-#lines])
            monitor.setTextColor(clrs[1])
            if (pos.x==nil) then

                monitor.write(players[y-#lines]..": Position Unkown")
            else
                
                monitor.write(players[y-#lines]..": Position:"..pos.x..","..pos.y..","..pos.z..",Dimension:"..pos.dimension)
            end
            

        end
        if((y-#lines)>#players)then
            break
        end



    end
    
    -- term.clear()
    sleep(0.5)

end
-- end